package chapter4.injection_contructure;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("messageRender")
public class StandardOutputMessageRender implements MessageRender {
	@Autowired
	private MessageProvider provider;
	@Autowired
	private ConfigurableMessageProvider configurableMessageProvider;

	@Override
	public void render() {
		if (provider == null) {
			System.out.println("PROVIDER IS NULL");
		} else {
			System.out.println("MESSAGE PROVIDER : " + provider.getMessage());
		}
		if (configurableMessageProvider == null) {
			System.out.println("CONFIGURABLE MESSAGE PROVIDER IS NULL");
		} else {
			System.out.println("CONFIGURABLE : "
					+ configurableMessageProvider.getMessage());
		}
	}

	@Override
	public void setMessageProvider(MessageProvider provider) {
		this.provider = provider;

	}

	@Override
	public MessageProvider getMessageProvider() {
		return provider;
	}

	@Override
	public void setConfigurableMessageProvider(
			ConfigurableMessageProvider provider) {
		this.configurableMessageProvider = provider;

	}

	@Override
	public ConfigurableMessageProvider getConfigurableMessageProvider() {
		return configurableMessageProvider;
	}

}
